#!/usr/bin/python
# coding:utf-8

from agent.redis_agent import RedisAgent
import signal
import sys
import os

sys.path.append(os.path.abspath(os.path.dirname(__file__)) + "/..")

from config.config import (
    LOG_REDIS_APP,
    LOG_REDIS_HOST,
    LOG_REDIS_PORT,
)


def signal_handler(signum, frame):
    print("Received signal:", signal)
    sys.exit()


if __name__ == "__main__":
    signal.signal(signal.SIGINT, signal_handler)
    signal.signal(signal.SIGTERM, signal_handler)
    agent = RedisAgent(
        LOG_REDIS_HOST, LOG_REDIS_PORT, app=LOG_REDIS_APP, outputpath="/home/log/"
    )
    agent.Init()
    agent.LogRun()
